fix: handle CORS preflight in reverse proxy during local dev#7164
Open
0xtlt wants to merge 1 commit intoShopify:mainfrom
Open
fix: handle CORS preflight in reverse proxy during local dev#71640xtlt wants to merge 1 commit intoShopify:mainfrom
0xtlt wants to merge 1 commit intoShopify:mainfrom
Conversation
Author
|
I have signed the CLA! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The HTTP reverse proxy used by
shopify app devdoes not handle CORS preflight (OPTIONS) requests, which breaks cross-origin fetch calls from UI extensions (e.g. Customer Account extensions calling the app backend through the Cloudflare tunnel).This PR intercepts OPTIONS requests at the proxy level and responds with the appropriate CORS headers, reflecting the client's
Origin,Access-Control-Request-MethodandAccess-Control-Request-Headers.Changes
http-reverse-proxy.ts: intercept OPTIONS before forwarding, respond 204 with CORS headershttp-reverse-proxy.test.ts: 2 new tests (preflight with headers + preflight without)Related: #5660